package com.team.six.bluecatshop.service;

import com.team.six.bluecatshop.domain.Address;
import com.team.six.bluecatshop.domain.Customer;
import com.team.six.bluecatshop.mapper.AddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService{

    @Autowired
    AddressMapper addressMapper;

    @Override
    public void addAddress(Customer customer, String customerAddress) {
        Address address = new Address();
        address.setCustomerId(customer.getCustomerId());
        address.setAddressPhone(customer.getCustomerPhone());
        address.setAddress(customerAddress);
        addressMapper.insert(address);
    }

    @Override
    public List<Address> findAddressByCustomerId(String customerId) {
        return addressMapper.findAddressByCustomerId(customerId);
    }

    @Override
    public void updateByPrimaryKeySelective(Address address) {
        addressMapper.updateByPrimaryKeySelective(address);
    }

    @Override
    public void insert(Address address) {
        addressMapper.insert(address);
    }

    @Override
    public Integer deleteByPrimaryKey(String id) {
        return addressMapper.deleteByPrimaryKey(id);
    }
}
